﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Master.Master" AutoEventWireup="true" CodeBehind="Create.aspx.cs" Inherits="UI.Admin.Role.Create" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        function summit_add_role() {
            $(".alert-success").remove(); $(".alert-danger").remove();
            var s = "";
            s = $.ajax({
                type: "POST",
                url: "AjaxAction.ashx",
                data: {
                    dowhat: "add_role",
                    Name: $("#Name").val(),
                    RoleInfoModelID: $("#RoleInfoModelID").val(),
                    IsAdmin: $("#IsAdmin").val(),
                    RoleEnabled: $("#RoleEnabled").val(),

                    ModelAdmin: $(".tree-item:eq(1)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    UserAdmin: $(".tree-item:eq(2)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    RoleAdmin: $(".tree-item:eq(3)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    LogAdmin: $(".tree-item:eq(4)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    SystemAdmin: $(".tree-item:eq(5)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    ColumnAdmin: $(".tree-item:eq(6)").find("i").attr("class") == "icon-ok" ? "True" : "false",
                    FileAdmin: $(".tree-item:eq(7)").find("i").attr("class") == "icon-ok" ? "True" : "false"
                },
                async: false
            }).responseText;
            if (s == "success") {
                $(".alert-success").remove(); $(".alert-danger").remove();
                $("#roleInfo").before("<div class=\"alert alert-block alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><i class=\"icon-remove\"></i></button><i class=\"icon-ok green\"></i>成功添加<strong class=\"green\">超级管理员</strong>这个角色.&nbsp;&nbsp;&nbsp;&nbsp;状态为:<strong class=\"green\">可用</strong></div>");
            }
            else { $(".alert-success").remove(); $(".alert-danger").remove(); $("#roleInfo").before("<div class='alert alert-block alert-danger'><button type='button' class='close' data-dismiss='alert'><i class='icon-remove'></i></button><small><strong><i class='icon-remove'></i>&nbsp;&nbsp;&nbsp;&nbsp;错误!</strong>&nbsp;&nbsp;&nbsp;&nbsp;" + s + "</small></div>"); }
        }
        function summit_clear() {
            $("#Name").val(""); $("#RoleInfoModelID").val("1"); $("#IsAdmin").val("True"); $("#RoleEnabled").val("True");
            for (var i = 1; i <= 7; i++) {
                $(".tree-item:eq(" + i + ")").removeClass("tree-selected");
                $(".tree-item:eq(" + i + ")").find("i").attr("class", "icon-remove");
            }
            $(".alert-success").remove(); $(".alert-danger").remove();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
		<h3 class="header lighter purple">
            <a href="Default.aspx" class="purple no-underline">角色管理</a>
			
			<small>
				<i class="icon-double-angle-right"></i>
				添加角色
			</small>
		</h3>
	</div><!-- /.page-header -->
    	
	<div class="row" id="roleInfo">
        <div class="col-xs-3">
            <label>角色名称：</label>
		    <input type="text" placeholder="输入角色名" id="Name" class="input-small"/>
        </div>
        <div class="col-xs-3 center">
            <label>角色信息模型：</label>
		    <select id="RoleInfoModelID">
			    <option value="1">基本模型&nbsp;&nbsp;</option>
			    <option value="2">教师模型&nbsp;&nbsp;</option>
			    <option value="3">学生模型&nbsp;&nbsp;</option>																
		    </select>
        </div>
        <div class="col-xs-3 center">
            <label>角色状态：</label>
			<select id="RoleEnabled">
				<option value="True">可用&nbsp;&nbsp;</option>
				<option value="False">不可用&nbsp;&nbsp;</option>																
			</select>
        </div>
        <div class="col-xs-3 center">
             <label>是否管理员：</label>
			<select id="IsAdmin">
				<option value="True">管理员&nbsp;&nbsp;</option>
				<option value="False">用户&nbsp;&nbsp;</option>																
			</select>
        </div>
		<div class="col-xs-12">           
            <div class="space-8"></div>
			<div class="row">               
                <div class="col-sm-6">
					<div class="widget-box">
						<div class="widget-header header-color-purple">
							<h4 class="lighter smaller">网站系统权限选择</h4>
						</div>

						<div class="widget-body">
							<div class="widget-main padding-8">
								<div id="tree1" class="tree"></div>					
							</div>
						</div>
					</div>
				</div>

                <div class="col-sm-6">				                 			                    
					<div class="widget-box">
						<div class="widget-header header-color-purple">
							<h4 class="lighter smaller">网站内容权限选择</h4>
						</div>

						<div class="widget-body">
							<div class="widget-main padding-8">
								
							</div>
                                                  
						</div>
					</div>
				</div>              
			</div>
            
              <div class="space-8"></div>
                <div class="clearfix form-actions">
				    <div class="col-md-offset-3 col-md-9">
					    <button class="btn btn-purple" type="button" onclick="summit_add_role()">
						    <i class="icon-ok bigger-110"></i>
						    添加
					    </button>

					    &nbsp; &nbsp; &nbsp;
					    <button class="btn" type="reset" onclick="summit_clear()">
						    <i class="icon-undo bigger-110"></i>
						    重置
					    </button>                        											
				    </div>
				</div>  			
		</div><!-- /.col -->
	</div><!-- /.row -->
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
	<script src="/Admin/assets/js/fuelux/fuelux.tree.min.js"></script>

    <script type="text/javascript">
        var $assets = "assets";//this will be used in fuelux.tree-sampledata.js
	</script>

    <script type="text/javascript">
        var DataSourceTree = function (options) {
            this._data = options.data;
            this._delay = options.delay;
        }

        DataSourceTree.prototype.data = function (options, callback) {
            var self = this;
            var $data = null;

            if (!("name" in options) && !("type" in options)) {
                $data = this._data;//the root tree
                callback({ data: $data });
                return;
            }
            else if ("type" in options && options.type == "folder") {
                if ("additionalParameters" in options && "children" in options.additionalParameters)
                    $data = options.additionalParameters.children;
                else $data = {}//no data
            }

            if ($data != null)//this setTimeout is only for mimicking some random delay
                setTimeout(function () { callback({ data: $data }); }, parseInt(Math.random() * 500) + 200);

            //we have used static data here
            //but you can retrieve your data dynamically from a server using ajax call
            //checkout examples/treeview.html and examples/treeview.js for more info
        };

        var tree_data = {
            'model': { name: '<span id="model">模型管理</span>', type: 'item' },
            'user': { name: '用户管理', type: 'item' },
            'role': { name: '角色管理', type: 'item' },
            'log': { name: '日志管理', type: 'item' },
            'system': { name: '系统管理', type: 'item' },
            'column': { name: '栏目管理', type: 'item' },
            'file': { name: '文件管理', type: 'item' },
        }
        var treeDataSource = new DataSourceTree({ data: tree_data });

        jQuery(function ($) {

            $('#tree1').ace_tree({
                dataSource: treeDataSource,
                multiSelect: true,
                loadingHTML: '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',
                'open-icon': 'icon-minus',
                'close-icon': 'icon-plus',
                'selectable': true,
                'selected-icon': 'icon-ok',
                'unselected-icon': 'icon-remove'
            });


            /**
            $('#tree1').on('loaded', function (evt, data) {
            });
    
            $('#tree1').on('opened', function (evt, data) {
            });
    
            $('#tree1').on('closed', function (evt, data) {
            });
   
            $('#tree1').on('selected', function (evt, data) {
            });
             */

        });

		</script>
</asp:Content>
